package com.wanmait.wisdom.manage.controller;

import com.wanmait.wisdom.entity.Unit;
import com.wanmait.wisdom.manage.service.ManageUnitService;
import com.wanmait.wisdom.util.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("manage/unit")
public class ManageUnitController {
    @Resource
    private ManageUnitService manageUnitService;
    @GetMapping("unitById")
    public AjaxResult UnitById(Integer id){
        return manageUnitService.findById(id);
    }

    @GetMapping("findUnitNumberOptions")
    public AjaxResult findUnitNumberOptions(Integer id){
        return manageUnitService.findUnitNumberOptions(id);
    }

    @PostMapping("checkunit")
    public AjaxResult checkUnit(@RequestBody Unit unit) {
        return manageUnitService.checkunit(unit);
    }
    @GetMapping("selectUnitById")
    public AjaxResult selectUnitById(Integer id) {
        List<Unit> unitList = manageUnitService.selectUnitById(id);
        return AjaxResult.success(unitList);
    }

    @GetMapping("/findUnitBybuildingid")
    public AjaxResult findUnitBybuildingid(Integer id){return manageUnitService.findUnitBybuildingid(id);}
}
